<?php
/**
 * Created by PhpStorm.
 * User: yf
 * Date: 2018/10/26
 * Time: 7:23 PM
 */

namespace App\Utility\Pool;


use EasySwoole\Component\Pool\AbstractPool;
use EasySwoole\EasySwoole\Config;

class MySQLPool extends AbstractPool
{
    protected function createObject()
    {
        return self::staticDBObj();
    }
    
    /**
     * TODO: 创建一个数据库连接对象
     * @return MySQLObject 连接对象
     */
    public static function staticDBObj($mysqldb = FALSE){
        if(!(isset($mysqldb['host']) && !empty($mysqldb['host']))){
            $mysqldb = Config::getInstance()->getConf('MYSQL');  //默认用MYSQL配置
        }
        $dbConf = new \EasySwoole\Mysqli\Config($mysqldb);
        return new MySQLObject($dbConf);
    }
    
}